package com.cetcs.kmga.dataManager.schedule;

import com.cetcs.kmga.dataManager.service.dataManager.RiskEventService;
import com.cetcs.kmga.dataManager.util.IConsumerMqMsgOper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * s事件操作消费类
 *
 * @author xutao
 * @version V1.0 创建时间：2017-10-16 11:26
 *          Copyright 2017 by CETC
 */
@Component
public class AuditEventMsgOper implements IConsumerMqMsgOper {

    @Autowired
    private RiskEventService riskEventService;

    //线程池
    private ExecutorService executorService = Executors.newCachedThreadPool();

    /**
     * 操作消息的实体类
     *
     * @param msg
     */
    @Override
    public void operBackMsg(String msg) throws Exception {
        executorService.execute(() -> {
            try {
                riskEventService.operRiskEventMsg(msg);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }
}
